package de.jmda.gen.java.impl;

import static de.jmda.core.util.StringUtil.sb;
import de.jmda.core.util.StringUtil;
import de.jmda.gen.GeneratorException;
import de.jmda.gen.impl.DefaultGenerator;
import de.jmda.gen.java.TypeParameterListGenerator;

/**
 * @author roger.jmda@gmail.com
 */
public class DefaultTypeParameterListGenerator
		extends DefaultGenerator
		implements TypeParameterListGenerator
{
	public DefaultTypeParameterListGenerator()
  {
	  super();
  }

	public DefaultTypeParameterListGenerator(String input)
  {
	  super(input);
  }

	@Override
  public StringBuffer generate() throws GeneratorException
  {
		StringBuffer result = super.generate();

		if (false == StringUtil.isBlank(result))
		{
			String prefix = "<";
			String suffix = ">";

			if (false == StringUtil.startsWith(result, prefix))
			{
				result = sb(prefix).append(result);
			}

			if (false == StringUtil.endsWith(result, suffix))
			{
				result.append(suffix);
			}
		}
		
		return result;
  }
}